Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiSuperSelect] Adding generated IDs to create accessible label and description #5364

Merged
merged 11 commits into from
Nov 17, 2021

Conversation

1Copenut
Copy link
Contributor

@1Copenut 1Copenut commented Nov 9, 2021

Summary

The EuiSuperSelect was flagging an error in axe-core where the div[role="listbox"] was missing an accessible label. I refactored it to include an accessible label and description. This improves screen reader UX by announcing a label and instructions for interacting with a keyboard. This PR closes #5292 and also closes #5367.

  • Generated class attribute IDs for aria-labelledby and aria-describedby in Super Select
  • Passing the title attribute to SR-only components in Color Palette Picker
  • Updated snapshot tests
  • Adding CHANGELOG entry to main

Probably non-breaking

I thought about adding the breaking change tag, but feel we're safe making this change for a couple of reasons:

  1. The screenReaderId prop is passed down from a class attribute that will always exist
  2. EuiSuperSelect is self-contained except for use in EuiColorPalettePicker, which was updated to include the new prop.
  3. EuiColorPalettePicker ended up needing a title attribute passed to child components so the <button> that's rendered by EuiSuperSelectControl always has an accessible label.

Screen reader testing

  • Tested with VoiceOver + Safari on MacOS Big Sur for a significant amount of time. Buttons are announcing their accessible label every time, and the listbox is announcing the instructions for use, and whether an option is "selected" or "text", as before. The selected option is announcing correctly when the listbox is closed, and VO identifies the button as having child options.

Screen Shot 2021-11-09 at 9 19 30 AM


Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

* Generated class attributes for aria-labelledby and aria-describedby
* Updated snapshot tests
* Adding CHANGELOG entry to main
Copy link
Contributor Author

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one explanatory comment for reasoning why I removed an attribute.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this!

Two AXE errors from CI:

11:33:54 Errors on tp://localhost:9999/#/forms/compressed-forms
11:38:10 [button-name]: Ensures buttons have discernible text
11:38:10   Help: https://dequeuniversity.com/rules/axe/4.1/button-name?application=axe-puppeteer
11:38:10   Elements:
11:38:10     - .euiSuperSelectControl
11:38:10 Errors on tp://localhost:9999/#/elastic-charts/creating-charts
11:39:15 [button-name]: Ensures buttons have discernible text
11:39:15   Help: https://dequeuniversity.com/rules/axe/4.1/button-name?application=axe-puppeteer
11:39:15   Elements:
11:39:15     - .euiSuperSelectControl
11:39:15 2 accessibility errors

CHANGELOG.md Outdated Show resolved Hide resolved
src/components/form/super_select/super_select.tsx Outdated Show resolved Hide resolved
@cchaos cchaos changed the title Adding generated IDs to create accessible label and description [EuiSuperSelect] Adding generated IDs to create accessible label and description Nov 9, 2021
* Removed `screenReaderId` from parent, passed directly to child component
* Added screen reader text to the Color Palette Picker button
* Updated snapshot tests
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

CHANGELOG.md Outdated Show resolved Hide resolved
* Refactored to add `aria-hidden` to color bars
* Added screen reader only text titles
* Fixes an axe-core issue with buttons needing discernible text in SuperSelect
* Added issue #5367 to CHANGELOG
Copy link
Contributor Author

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last changes finished and tested. PR update incoming shortly.

Copy link
Contributor Author

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope expanded a bit because of Color Palette Picker. I found a way to announce the Super Select listbox options consistently, and always have an accessible label for the button when the listbox is closed.

<span>{title}</span>
</EuiScreenReaderOnly>
<span
aria-hidden="true"
Copy link
Contributor Author

@1Copenut 1Copenut Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aria-hidden="true" is to ensure the color blocks are ignored by screen readers, and the only accessible text for options is the title string.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

@1Copenut
Copy link
Contributor Author

@cchaos Added requested comment to both components.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

@1Copenut
Copy link
Contributor Author

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A changelog note I'd missed earlier, + a small code simplification

CHANGELOG.md Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

@1Copenut 1Copenut requested a review from cchaos November 15, 2021 18:01
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💟 All the a11y PR's!! LGTM, mostly as a code check, I didn't run through a screen-reader to confirm.

@1Copenut
Copy link
Contributor Author

💟 All the a11y PR's!! LGTM, mostly as a code check, I didn't run through a screen-reader to confirm.

@cchaos I ran it through VoiceOver on MacOS. I'll pass a preview URL to Zuhair and see if he's got time to test with NVDA and JAWS for coverage.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, and with such a clean change set! This LGTM, tested functionality out in the PR's canary docs

Copy link
Contributor

@breehall breehall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I pulled the branch and tested with Voiceover (macOS BigSur). Awesome job!

@zuhairmahd
Copy link

@cchaos and myself went through the URLS with JAWS and NVDA. Both screen readers behaved as expected but we note the following minor issues:

  1. The describedby text was not reading in JAWS but was reading in NVDA
  2. The describedby label tries to be helpful by informing the user of the number of items in the list, but fails to take into account disabled items.

@1Copenut will take out the number of items from the describedby , after which this should be complete. I will research why JAWS is not reading, and will open a future enhancement if a fix is needed on our end.

@cchaos
Copy link
Contributor

cchaos commented Nov 17, 2021

I did? Was I sleep-walking? 🤣

@zuhairmahd
Copy link

I did? Was I sleep-walking? 🤣

Thought you did! Maybe I was falling asleep! :-)

By the way, no need to do anything with JAWS since the default verbosity is set to ignore describedby labels.

Untitled

@1Copenut
Copy link
Contributor Author

Great find @zuhairmahd. I'm surprised the default verbosity ignores describedby labels, but knowing this will help inform future decisions. I wonder if we should start a corpus of defaults, unique behaviors, et al. ?

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5364/

@1Copenut 1Copenut merged commit cf4f132 into elastic:main Nov 17, 2021
@1Copenut 1Copenut deleted the tpierce-eui-5292 branch November 17, 2021 16:32
1Copenut added a commit that referenced this pull request Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants